<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@include file="/common/commonTag.jsp"%>
<%@include file="/common/commonJS.jsp"%>
<!DOCTYPE html>
<html>
<head>
</head>
<body>
	<jsp:include page="../alert.jsp" flush="true"/>
	<s:property value="msg"/>
	<form id="listForm" name="listForm" method="post">
		<input type="hidden" name="id" id="id">
		<jsp:include page="../tableAction.jsp" flush="true" />
		<table id="listTable" class="table table-bordered table-condensed table-hover table-striped"> 
		    <thead>
               <tr>
               	   <th>
               	       <input type="checkBox" onclick="$.checkAllAndInvert(this,'ids')">
               	   </th>
                   <th>No.</th>
                   <th>UserName</th>
                   <th>Password</th>
                   <th>Status</th>
                   <th>Create Date</th>
                   <th></th>
              </tr>
            </thead>
            <tbody>
	            <c:forEach items="${pager.result}" var="entity" varStatus="status">
	            	<tr>
		            	<td>
	            			<input type="checkbox" value="${entity.id}" name="ids">
	            		</td>
	            		<td>
	            			${status.index + 1}
	            		</td>
	            		<td>
	            			${entity.username}
	            		</td>
	            		<td>
	            			${entity.password}
	            		</td>
	            		<td>
	            			<c:if test="${entity.status == 1}">Normal</c:if>
	            			<c:if test="${entity.status == 2}"><span class="label label-warning">Not Activated</span></c:if>
	            			<c:if test="${entity.status == 3}"><span class="label label-warning">Locked</span></c:if>
	            			<c:if test="${entity.status == 4}"><span class="label label-warning">Cancelled</span></c:if>
	            		</td>
	            		<td>
	            			${entity.createDateStr}
	            		</td>
	            		<td>
	            			<a href="#none" onclick="removes(${entity.id})"><i class="icon-remove"></i></a>
	            			<a href="#none" onclick="edit('${entity.id}')"><i class="icon-edit"></i></a>
	            			<a href="#none" onclick="view('${entity.id}')"><i class="icon-search"></i></a>
	            		</td>
            		</tr>
	            </c:forEach>
            </tbody>
		</table>
		<jsp:include page="../pager.jsp" flush="true"/>
	</form>
</body> 
<script type="text/javascript">
	$(function() 
	{
		setNewAction($.path + "/framework/user/userInput.jsp");
		setRemoveAllAction($.path + "/userAction!removeAll.action");
		setExportExcelAction($.path + "/userAction!exportExcel.action");
		setImportExcelAction($.path + "/userAction!importExcel.action");
		setSearch($.path+"/userAction!search.action","userVo");
		setPageURL($.path+"/userAction!list.action");
		//setPrintAction("#listTable");
	});
	
	// remove user
	function removes(id)
	{
		if(confirm("Are you want to delete ?")){
			$("#id").val(id);
			$("#listForm").attr("action",$.path+"/userAction!remove.action").submit();
		}
	}
	
	// edit user
	function edit(id)
	{
		$("#id").val(id);
		$("#listForm").attr("action",$.path+"/userAction!edit.action").submit();
	}
	
	// view user
	function view(id)
	{
		$("#id").val(id);
		$("#listForm").attr("action",$.path+"/userAction!view.action").submit();
	}
</script> 
</html>
